<template>
    <div>
        <div class="search">
            <!-- 查询 -->
            <el-form :inline="true" :model="searchData" size="mini" class="demo-form-inline">

                <el-form-item label="">
                    <el-input v-model="searchData.keywords" placeholder="楼盘字典名字、拼音缩写、开发商名字、开发商手机号"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="search">查询</el-button>
                    <el-button type="primary" @click="add">添加楼盘字典</el-button>
                </el-form-item>
            </el-form>
        </div>

        <div class='content'>
            
            <!-- 添加楼盘字典 -->
            <el-dialog :title="dialogtitle" v-if="centerDialogVisible" :visible.sync="centerDialogVisible" width="60%" center>
                <!--传参：  tjstatus 页面状态（1为新增  2为修改） editcont修改楼盘字典时的数据         事件：  listdata刷新列表   dialogstatus关闭弹窗 -->
                <Editbuildingdictionary :tjstatus = tjstatus :editcont = editcont @listdata="listdata" @dialogstatus="dialogstatus"/>
            </el-dialog>
            <!-- 添加栋座 -->
            <el-dialog :title="peddialogtitle" :visible.sync="pedDialogVisible" width="672px" center>
                <el-form :model="pedform" :rules="pedrules" size="mini" inline ref="pedform" label-width="140px" class="demo-ruleForm">
                    <el-form-item label="栋座名称" prop="b_building">
                        <el-input v-model="pedform.b_building"></el-input>
                    </el-form-item>
                    <el-form-item label="" prop="b_building_unit">
                        <el-select v-model="pedform.b_building_unit" placeholder="" class="mini-select">
                            <el-option v-for="(item,index) in pedinfo.building" :key="index" :label="item" :value="index"></el-option>
                        </el-select>	
                    </el-form-item>
                    <el-form-item label="总层数" prop="b_layer_num">
                        <el-input v-model="pedform.b_layer_num" type="number" min="1"></el-input>层
                    </el-form-item>
                    <el-form-item label="梯户数" prop="b_ladder_num">
                        <el-input v-model="pedform.b_ladder_num" type="number" min="1"></el-input>梯
                    </el-form-item>
                    <el-form-item label="" prop="b_door_num">
                        <el-input v-model="pedform.b_door_num" type="number" min="1"></el-input>户
                    </el-form-item>
                    <el-form-item label="单元数" prop="b_cell_unit">
                        <el-select v-model="pedform.b_cell_unit" placeholder="" class="mini-select">
                            <el-option v-for="(item,index) in pedinfo.cell" :key="index" :label="item" :value="index"></el-option>
                        </el-select>有
                    </el-form-item>
                    <el-form-item label="" prop="b_cell_num">
                        <el-input v-model="pedform.b_cell_num" type="number" min="1"></el-input>单元
                    </el-form-item>
                </el-form>
                <span slot="footer" class="dialog-footer">
                    <el-button @click="cancel('pedform',2)" size="mini">取 消</el-button>
                    <el-button type="primary" @click="submit('pedform',2)" size="mini">确 定</el-button>
                </span>
            </el-dialog>
            <!-- 批量添加栋座 -->
            <el-dialog title="批量添加栋座" :visible.sync="bacthpedDialogVisible" width="877px" center>
                <el-form :model="bacthform" :rules="bacthrules" size="mini" inline ref="bacthform" label-width="95px" class="demo-ruleForm">
                    <el-form-item label="栋座名称" prop="b_building_prefix">
                        <el-input v-model="bacthform.b_building_prefix" class="smallinp" style="width: 150px;"></el-input>
                    </el-form-item>
                    <el-form-item label="" prop="b_type">
                        <el-radio v-model="bacthform.b_type" label="1">
                            数字
                        </el-radio>
                    </el-form-item>
                    <el-form-item label="" prop="b_start_num">   
                        <el-input v-model="bacthform.b_start_num" class="smallinp" type="number" min="1"></el-input>至
                    </el-form-item>
                    <el-form-item label="" prop="b_end_num">
                        <el-input v-model="bacthform.b_end_num" class="smallinp" type="number" min="1"></el-input>
                    </el-form-item>
                    <el-form-item label="" prop="b_type">
                        <el-radio v-model="bacthform.b_type" label="2">
                            字母
                        </el-radio>
                    </el-form-item>
                    <el-form-item label="" prop="b_start_en">
                        <el-input v-model="bacthform.b_start_en" class="smallinp"></el-input>至
                    </el-form-item>
                    <el-form-item label="" prop="b_end_en">
                        <el-input v-model="bacthform.b_end_en" class="smallinp"></el-input>
                    </el-form-item>
                    <el-form-item label="" prop="b_building_unit">
                        <el-select v-model="bacthform.b_building_unit" placeholder="" style="width:65px;" class="mini-select">
                            <el-option v-for="(item,index) in pedinfo.building" :key="index" :label="item" :value="index"></el-option>
                        </el-select>	
                    </el-form-item>
                    <el-form-item label="总层数" prop="b_layer_num">
                        <el-input v-model="bacthform.b_layer_num" class="smallinp" type="number" min="1"></el-input>层
                    </el-form-item>
                    <el-form-item label="梯户数" prop="b_ladder_num">
                        <el-input v-model="bacthform.b_ladder_num" class="smallinp" type="number" min="1"></el-input>梯
                    </el-form-item>
                    <el-form-item label="" prop="b_door_num">
                        <el-input v-model="bacthform.b_door_num" class="smallinp" type="number" min="1"></el-input>户
                    </el-form-item>
                    <el-form-item label="单元数" prop="b_cell_unit">
                        <el-select v-model="bacthform.b_cell_unit" placeholder="" class="mini-select">
                            <el-option v-for="(item,index) in pedinfo.cell" :key="index" :label="item" :value="index"></el-option>
                        </el-select>有
                    </el-form-item>
                    <el-form-item label="" prop="b_cell_num">
                        <el-input v-model="bacthform.b_cell_num" class="smallinp" type="number" min="1"></el-input>单元
                    </el-form-item>
                </el-form>
                <span slot="footer" class="dialog-footer">
                    <el-button @click="cancel('bacthform',3)" size="mini">取 消</el-button>
                    <el-button type="primary" @click="submit('bacthform',3)" size="mini">确 定</el-button>
                </span>
            </el-dialog>
            <!-- 栋座信息列表 -->
            <el-dialog title="栋座信息" :visible.sync="pedestalDialogVisible" width="75%" center>
                <el-button type="primary" @click="padd" size="mini">添加栋座信息</el-button>
                <el-button type="primary" @click="batchadd" size="mini">批量添加</el-button>
                <el-button type="primary" @click="batchdel" size="mini">批量删除</el-button>
                <el-table ref="multipleTable" :data="pedestallist.data" tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange">
                    <el-table-column type="selection" width="55"></el-table-column>
                    <el-table-column align="center" prop="b_id" label="栋座ID" width="120"></el-table-column>
                    <el-table-column align="center" prop="b_building" label="栋座名称" width="120"></el-table-column>
                    <el-table-column align="center" prop="b_building_unit" label="栋座名称对应单位" width="120"></el-table-column>
                    <el-table-column align="center" prop="b_layer_num" label="总层数" width="120"></el-table-column>
                    <el-table-column align="center" prop="b_ladder_num" label="梯数" width="120"></el-table-column>
                    <el-table-column align="center" prop="b_door_num" label="户数" width="120"></el-table-column>
                    <el-table-column align="center" prop="b_cell_num" label="单元数" width="120"></el-table-column>
                    <el-table-column align="center" prop="b_cell_unit" label="单元数对应单位" width="120"></el-table-column>
                    <el-table-column align="center" prop="b_created_at" label="创建时间" width="120"></el-table-column>
                    <el-table-column align="center" prop="b_updated_at" label="修改时间" width="120"></el-table-column>
                    <el-table-column fixed="right" label="操作" width="120">
                    <template slot-scope="scope">
                        <el-button @click.native.prevent="edit(scope.row,2)" type="text" size="small">编辑</el-button>
                        <el-button @click.native.prevent="deltest(scope.row,2,1)" type="text" size="small">删除</el-button>
                    </template>
                    </el-table-column>
                </el-table>
                <!-- 分页 -->
                <el-pagination :current-page="pedestalcurrent" @current-change="pedestalChange" :total="pedestallist.total" style="margin-top:30px;"></el-pagination>
            </el-dialog>
            <div class='list'>
                <el-table ref="multipleTable" :data="list.data" tooltip-effect="dark" style="width: 100%">

                    <el-table-column align="center" prop="w_id" label="楼盘字典ID" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_name" label="楼盘字典" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_as_name" label="别名" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_province_name" label="省" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_city_name" label="市" width="120"></el-table-column>
                    <!-- <el-table-column align="center" prop="w_area_name" label="区县" width="120"></el-table-column> -->
                    <el-table-column align="center" prop="w_metro_name" label="地铁" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_ring_name" label="环线" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_building_house" label="建房年代" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_property" label="产权" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_resume_address" label="概要地址" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_info_address" label="详细地址" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_avg_price" label="售均价" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_admin_price" label="管理费" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_remark" label="备注" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_acreage" label="建筑面积" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_structure_name" label="结构" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_w_land" label="土地等级" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_house_num" label="总户数" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_wall_name" label="外墙" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_land_num" label="地号" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_owner" label="开发商" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_owner_phone" label="开发商电话" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_property_name" label="物业" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_property_phone" label="物业电话" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_type_name" label="物业类型ID" width="120"></el-table-column>
                    <el-table-column align="center" prop="w_purpose_name" label="用途" width="120"></el-table-column>

                    <el-table-column fixed="right" label="操作" width="120">
                    <template slot-scope="scope">
                        <el-button @click.native.prevent="edit(scope.row,1)" type="text" size="small">编辑</el-button>
                        <el-button @click.native.prevent="deltest(scope.row,1)" type="text" size="small">删除</el-button>
                        <el-button @click.native.prevent="pedestal(scope.row)" type="text" size="small">栋座信息</el-button>
                    </template>
                    </el-table-column>
                </el-table>
                <!-- 分页 -->
                <el-pagination :current-page="current" @current-change="handleCurrentChange" :total="list.total" style="margin-top:30px;"></el-pagination>
            </div>
        </div>
    </div>
</template>
<style>
    .home .view-content{
        width: 87%;
    }
    .el-form-item__label,.el-form-item__content{
        font-size: 12px;
    }
    .el-input{
        padding-right: 5px;
    }
    .el-select-dropdown__item{
        font-size: 12px;
        padding: 0px 10px;
        height: 26px;
        line-height: 26px;
    }
    .el-input,.el-date-editor.el-input{
        width: 145px;
    }
    .smallinp.el-input{
        width: 65px;
    }
    .mini-select>.el-input{
        width: 65px;
    }
</style>

<script>
    import conf from '../../config/userconf.js'
    import permconfig from '../../config/permconfig.js'
  export default {
    data() {
        var validatePhone = (rule,value,callback) => {    //正则手机号

            var MobileRegex = /^1[3|4|5|7|8][0-9]{9}$/;
            if (!MobileRegex.test(value)) {
                callback(new Error('手机号格式不正确！'))
            } else {
                callback();
            }
        };
        var validateTel = (rule,value,callback) => {    //正则座机号
            var MobileRegex = /(^(\d{3,4}-)\d{7,8}$)|(^\d{7,8}$)/;
            if (!MobileRegex.test(value)) {
                callback(new Error('电话格式不正确！'))
            } else {
                callback();
            }
        };
        var validateaz = (rule,value,callback) => {    //正则字母

            var MobileRegex = /^[a-zA-Z]$/;
            if (!MobileRegex.test(value)) {
                callback(new Error('只能输入字母格式哦~'))
            } else {
                callback();
            }
        };
        return {
            list:[],
            pedestallist: [],
            searchData:{
                keywords:'',
            },
            pedform: {
                b_building: '',
                b_building_unit: '',
                b_layer_num: '',
                b_ladder_num: '',
                b_door_num: '',
                b_cell_num: '0',
                b_cell_unit: '',
            },
            bacthform:{
                b_building_prefix: '',
                b_building_unit: '',
                b_layer_num: '',
                b_ladder_num: '',
                b_door_num: '',
                b_cell_num: '0',
                b_cell_unit: '',
                b_type: '1',
                b_start_num: '1',
                b_start_en: 'A',
                b_end_num: '10',
                b_end_en: 'H',
            },
            typeVal: '',
            dialogtitle:'添加楼盘字典',
            peddialogtitle:'添加栋座信息',
            centerDialogVisible:false,
            pedestalDialogVisible: false,
            pedDialogVisible: false,
            bmId: '',  //部门id
            current: 1,
            pedestalcurrent: 1,
            // info: [],
            pedinfo: [],
            // defaultCity: {},
            pedrules:{
                b_building:[
                    { required: true, message: '请输入栋座名称', trigger: 'blur' }
                ],
                b_building_unit:[
                    { required: true, message: '请选择', trigger: 'change' }
                ],
                b_cell_num:[
                    { required: true, message: '请输入单元数', trigger: 'blur' }
                ],
                b_cell_unit:[
                    { required: true, message: '请选择', trigger: 'change' }
                ],
            },
            bacthrules: {
                b_building_prefix:[
                    { required: true, message: '请输入栋座名称', trigger: 'blur' }
                ],
                b_building_unit:[
                    { required: true, message: '请选择', trigger: 'change' }
                ],
                b_cell_num:[
                    { required: true, message: '请输入单元数', trigger: 'blur' }
                ],
                b_cell_unit:[
                    { required: true, message: '请选择', trigger: 'change' }
                ],
                b_start_num:[
                    { required: true, message: '请输入开始编号', trigger: 'blur' }
                ],
                b_start_en:[
                    { required: true, message: '请输入开始编号', trigger: 'blur' },
                    {
                        validator:(rule,value,callback)=>{
                            console.log('-------------------',value);
                            var MobileRegex = /^[a-zA-Z]$/;
                            if (!MobileRegex.test(value)) {
                                callback(new Error('只能输入字母格式哦~'))
                            } else {
                                callback();
                            }
                        }, trigger: 'blur'
                    }
                ],
                b_end_num:[
                    { required: true, message: '请输入结束编号', trigger: 'blur' }
                ],
                b_end_en:[
                    { required: true, message: '请输入结束编号', trigger: 'blur' },
                    { validator: validateaz, trigger: 'blur'}
                ],
            },
            b_w_id: '',   //楼盘id
            b_id: '',  //栋座信息ID
            selection: '',  //栋座信息  多选操作的内容信息
            batchId: '',  //栋座信息  多选操作的id
            batchtype: 1,  //栋座   1单删  2多删
            bacthpedDialogVisible: false,

            tjstatus: 1,  //页面类型   1为新增    2为修改
            editcont: {},  // 页面修改时的数据内容
        }
    },
    methods: {
        /* 列表*/
        getList (data=Object()){
            var ownerPermission = window.localStorage.getItem('authories');
                var arr = ownerPermission.split(',');
                if(arr.indexOf(permconfig.qx_qita_chankanloupanzidian)  == -1){
                    alert('您没有该功能的权限');
                    return;
                }
            data.page = this.current;
            conf.buildingdictionary.list(data,(state,res)=>{
                if (state == 'success'&&res.data.code == 0){
                    this.list = res.data.data;   
                }else if(state == 'success'&&res.data.code != 0){
                    if(res.data.code == 401){
                        this.$router.push({name:'login'});   //登陆态失效，跳转至登录页
                    }else if(res.data.code == -404){
                        this.list = [];
                    }else{
                        this.$message({
                            type: 'info',
                            message: res.data.msg
                        });
                    }
                }
            })
        },
        /* 栋座列表*/
        pedestalList (val,data=Object()){
            var ownerPermission = window.localStorage.getItem('authories');
                var arr = ownerPermission.split(',');
                if(arr.indexOf(permconfig.qx_qita_chankanloupanzidian)  == -1){
                    alert('您没有该功能的权限');
                    return;
                }

            data.w_id = val;
            data.page = this.pedestalcurrent;
            conf.buildingdictionary.plist(data,(state,res)=>{
                if (state == 'success'&&res.data.code == 0){
                    this.pedestallist = res.data.data;   
                }else if(state == 'success'&&res.data.code != 0){
                    if(res.data.code == 401){
                        this.$router.push({name:'login'});   //登陆态失效，跳转至登录页
                    }else if(res.data.code == -404){
                        this.pedestallist = [];
                    }else{
                        this.$message({
                            type: 'info',
                            message: res.data.msg
                        });
                    }
                }
            })
        },
        /* 添加页面下拉数据*/
        optdata (data=Object()){
            conf.buildingdictionary.optdata(data,(state,res)=>{
                if (state == 'success'&&res.data.code == 0){
                    this.info = res.data.data;   
                }else if(state == 'success'&&res.data.code != 0){
                    if(res.data.code == 401){
                        this.$router.push({name:'login'});   //登陆态失效，跳转至登录页
                    }else if(res.data.code == -404){
                        this.info = [];
                    }else{
                        this.$message({
                            type: 'info',
                            message: res.data.msg
                        });
                    }
                }
            })
        },
        /*栋座信息 添加页面下拉数据*/
        pedoptdata (data=Object()){
            conf.buildingdictionary.poptdata(data,(state,res)=>{
                if (state == 'success'&&res.data.code == 0){
                    this.pedinfo = res.data.data;   
                }else if(state == 'success'&&res.data.code != 0){
                    if(res.data.code == 401){
                        this.$router.push({name:'login'});   //登陆态失效，跳转至登录页
                    }else if(res.data.code == -404){
                        this.pedinfo = [];
                    }else{
                        this.$message({
                            type: 'info',
                            message: res.data.msg
                        });
                    }
                }
            })
        },
        /*查询 */
        search () {
            let data  = this.searchData;
            this.getList(data);
        },
        /*取消 */
        cancel (formName,type) {
            console.log(formName,type);
            if(type === 1){  //楼盘字典  取消
                this.centerDialogVisible = false;
            }else if(type === 2){  // 栋座   取消
                this.pedDialogVisible = false;
            }else if(type === 3){  // 批量添加栋座   取消
                this.bacthpedDialogVisible = false;
            }
            this.$refs[formName].resetFields();
        },
        
        // /*提交 */
        submit (formName,type) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    if(type === 1){  //楼盘字典  提交
                        this.judgeprimise();
                    }else if(type === 2){  // 栋座   提交
                        this.pedjudgeprimise();
                    }else if(type === 3){  // 栋座   批量提交
                        this.batchjudgeprimise();
                    }
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        },
        /*判断提交   栋座*/
        pedjudgeprimise (data=Object()) {
            if (this.peddialogtitle == '添加栋座信息') {
                var ownerPermission = window.localStorage.getItem('authories');
                var arr = ownerPermission.split(',');
                if(arr.indexOf(permconfig.qx_qita_tianjialoupanzidian)  == -1){
                    alert('您没有该功能的权限');
                    return;
                }
                data = this.pedform;
                data.b_w_id = this.b_w_id;
                conf.buildingdictionary.padd(data,(state,res)=>{
                    if (state == 'success'&&res.data.code == 0){
                        this.pedestalList(this.b_w_id);
                        this.pedDialogVisible = false;
                        this.$message({
                            type: 'success',
                            message: '添加成功!'
                        });
                    }else if(state == 'success'&&res.data.code != 0){
                        if(res.data.code == 401){
                            this.$router.push({name:'login'});   //登陆态失效，跳转至登录页
                        }else{
                            this.$message({
                                type: 'info',
                                message: res.data.msg
                            });
                        }
                    }
                })
            }else if (this.peddialogtitle == '修改楼盘字典栋座信息'){
                var ownerPermission = window.localStorage.getItem('authories');
                var arr = ownerPermission.split(',');
                if(arr.indexOf(permconfig.qx_qita_xiugailoupanzidian)  == -1){
                    alert('您没有该功能的权限');
                    return;
                }
                data = this.pedform;
                data.b_w_id = this.b_w_id;
                data.b_id = this.b_id;
                conf.buildingdictionary.pedit(data,(state,res)=>{
                    if (state == 'success'&&res.data.code == 0){
                        this.pedestalList(this.b_w_id);
                        this.pedDialogVisible = false;
                        this.$message({
                            type: 'success',
                            message: '修改成功!'
                        });
                    }else if(state == 'success'&&res.data.code != 0){
                        if(res.data.code == 401){
                            this.$router.push({name:'login'});   //登陆态失效，跳转至登录页
                        }else{
                            this.$message({
                                type: 'info',
                                message: res.data.msg
                            });
                        }
                    }
                })
            }
        },
        /*判断提交   栋座*/
        batchjudgeprimise (data=Object()) {
            data.b_building_prefix = this.bacthform.b_building_prefix;
            data.b_building_unit = this.bacthform.b_building_unit;
            data.b_layer_num = this.bacthform.b_layer_num;
            data.b_ladder_num = this.bacthform.b_ladder_num;
            data.b_door_num = this.bacthform.b_door_num;
            data.b_cell_num = this.bacthform.b_cell_num;
            data.b_cell_unit = this.bacthform.b_cell_unit;
            data.b_type = this.bacthform.b_type;
            if(this.bacthform.b_type == 1){  //生成方式 1数字 2大写英文字母
                data.b_start = this.bacthform.b_start_num;
                data.b_end = this.bacthform.b_end_num;
            }else if(this.bacthform.b_type == 2){
                data.b_start = this.bacthform.b_start_en;
                data.b_end = this.bacthform.b_end_en;
            }
            data.b_w_id = this.b_w_id;
            conf.buildingdictionary.batchadd(data,(state,res)=>{
                if (state == 'success'&&res.data.code == 0){
                    this.pedestalList(this.b_w_id);
                    this.bacthpedDialogVisible = false;
                    this.$message({
                        type: 'success',
                        message: '添加成功!'
                    });
                }else if(state == 'success'&&res.data.code != 0){
                    if(res.data.code == 401){
                        this.$router.push({name:'login'});   //登陆态失效，跳转至登录页
                    }else{
                        this.$message({
                            type: 'info',
                            message: res.data.msg
                        });
                    }
                }
            })
        },
        /*增 */
        add (formName) {
            var ownerPermission = window.localStorage.getItem('authories');
                var arr = ownerPermission.split(',');
                if(arr.indexOf(permconfig.qx_qita_tianjialoupanzidian)  == -1){
                    alert('您没有该功能的权限');
                    return;
                }
            this.tjstatus = 1;
            this.dialogtitle = '添加楼盘字典';
            this.centerDialogVisible = true;
        },
        // 删除
        deltest (row,type,batchtype,data=Object()) {
            console.log(row,type,batchtype,data);
            if(batchtype){
                this.batchtype = 1;
            }
            if(type === 1){
                var ownerPermission = window.localStorage.getItem('authories');
                var arr = ownerPermission.split(',');
                if(arr.indexOf(permconfig.qx_qita_shanchuloupanzidian)  == -1){
                    alert('您没有该功能的权限');
                    return;
                }
                this.$confirm('确认删除楼盘字典 "'+row.w_name+'" ?', '删除楼盘字典', {  
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {

                    data.id = row.w_id;
                    conf.buildingdictionary.del(data,(state,res)=>{
                        if (state == 'success'&&res.data.code == 0){
                            this.getList();
                            this.$message({
                                type: 'success',
                                message: '删除成功!'
                            });
                        }else if(state == 'success'&&res.data.code != 0){
                            if(res.data.code == 401){
                                this.$router.push({name:'login'});   //登陆态失效，跳转至登录页
                            }else{
                                this.$message({
                                    type: 'info',
                                    message: res.data.msg
                                });
                            }
                        }
                    })

                }).catch(() => {
                    this.$message({
                    type: 'info',
                    message: '已取消删除'
                    });          
                });
            }else if(type === 2){
                var ownerPermission = window.localStorage.getItem('authories');
                var arr = ownerPermission.split(',');
                if(arr.indexOf(permconfig.qx_qita_shanchuloupanzidian)  == -1){
                    alert('您没有该功能的权限');
                    return;
                }
                this.$confirm('确认要永久删除已选定的栋座吗?', '删除栋座', {  
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    if(this.batchtype == 1){  //单删
                        data.b_id = row.b_id;
                    }else if(this.batchtype == 2){  //多删
                        const arr = [];
                        for (var i=0;i<row.length;i++){
                            arr.push(row[i].b_id);
                        }
                        this.batchId = arr.toString();
                        data.b_id = this.batchId;
                    }
                    
                    conf.buildingdictionary.pdel(data,(state,res)=>{
                        if (state == 'success'&&res.data.code == 0){
                            this.pedestalList(this.b_w_id);
                            this.$message({
                                type: 'success',
                                message: '删除成功!'
                            });
                        }else if(state == 'success'&&res.data.code != 0){
                            if(res.data.code == 401){
                                this.$router.push({name:'login'});   //登陆态失效，跳转至登录页
                            }else{
                                this.$message({
                                    type: 'info',
                                    message: res.data.msg
                                });
                            }
                        }
                    })

                }).catch(() => {
                    this.$message({
                    type: 'info',
                    message: '已取消删除'
                    });          
                });
            }
        },
        /**改*/
        edit (val,type) {
            this.tjstatus = 2;
            console.log(val);
            if(type === 1){
                 var ownerPermission = window.localStorage.getItem('authories');
                var arr = ownerPermission.split(',');
                if(arr.indexOf(permconfig.qx_qita_xiugailoupanzidian)  == -1){
                    alert('您没有该功能的权限');
                    return;
                }
                this.dialogtitle = '修改楼盘字典信息';
                this.editcont = val;  //传值给子组件
                this.bmId = val.w_id;
                this.centerDialogVisible = true;
            }else if(type === 2){
                 var ownerPermission = window.localStorage.getItem('authories');
                var arr = ownerPermission.split(',');
                if(arr.indexOf(permconfig.qx_qita_xiugailoupanzidian)  == -1){
                    alert('您没有该功能的权限');
                    return;
                }
                this.peddialogtitle = '修改楼盘字典栋座信息';
                this.pedform = {
                    b_building: val.b_building,
                    b_building_unit: val.b_building_unit,
                    b_layer_num: val.b_layer_num,
                    b_ladder_num: val.b_ladder_num,
                    b_door_num: val.b_door_num,
                    b_cell_num: val.b_cell_num,
                    b_cell_unit: val.b_cell_unit,
                },
                this.b_id = val.b_id;
                this.pedDialogVisible = true;
            }
            
        },
        // 切换页码
        handleCurrentChange(val) {
            this.current = val;
            this.getList();
        },
        // 切换页码
        pedestalChange(val){
            this.pedestalcurrent = val;
            this.pedestalList(this.b_w_id);
        },
        //栋座信息
        pedestal(val){
            console.log(val);
            this.b_w_id = val.w_id;
            this.pedestalList(val.w_id);
            this.pedestalDialogVisible = true;
        },
        padd(formName){
             var ownerPermission = window.localStorage.getItem('authories');
                var arr = ownerPermission.split(',');
                if(arr.indexOf(permconfig.qx_qita_tianjialoupanzidian)  == -1){
                    alert('您没有该功能的权限');
                    return;
                }
            this.peddialogtitle = '添加栋座信息';
            this.pedDialogVisible = true;
        },
        //批量添加
        batchadd(){
             var ownerPermission = window.localStorage.getItem('authories');
                var arr = ownerPermission.split(',');
                if(arr.indexOf(permconfig.qx_qita_tianjialoupanzidian)  == -1){
                    alert('您没有该功能的权限');
                    return;
                }
            this.bacthpeddialogtitle = '批量添加栋座';
            this.bacthpedDialogVisible = true;
        },
        //多选
        handleSelectionChange(selection){
            console.log(selection);
            this.selection = selection;
        },
        //批量删除
        batchdel(){
            var ownerPermission = window.localStorage.getItem('authories');
                var arr = ownerPermission.split(',');
                if(arr.indexOf(permconfig.qx_qita_shanchuloupanzidian)  == -1){
                    alert('您没有该功能的权限');
                    return;
                }
            this.batchtype = 2;
            this.deltest(this.selection,2);
        },
        //列表数据更新
        listdata(){
            this.getList();
        },
        //关闭楼盘字典弹框
        dialogstatus(){
            this.centerDialogVisible = false;
        },
    },
    mounted (){
        this.$nextTick(function(){
            this.getList();
            this.optdata();
            this.pedoptdata();
        })
    },
        
  }
</script>